Skip to content

Fix #500: [Model] SequencingToMinimizeMaximumCumulativeCost#674

Open
GiggleLiu wants to merge 6 commits intomainfrom
issue-500-sequencing-to-minimize-maximum-cumulative-cost
Open

Fix #500: [Model] SequencingToMinimizeMaximumCumulativeCost#674
GiggleLiu wants to merge 6 commits intomainfrom
issue-500-sequencing-to-minimize-maximum-cumulative-cost

Conversation

@GiggleLiu
Copy link
Contributor

Summary

Add the implementation plan for SequencingToMinimizeMaximumCumulativeCost, including the model design, CLI wiring, tests, and paper work.

Fixes #500

@codecov
Copy link

codecov bot commented Mar 16, 2026

Codecov Report

❌ Patch coverage is 97.37828% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 97.04%. Comparing base (dfcc313) to head (994f414).

Files with missing lines Patch % Lines
.../sequencing_to_minimize_maximum_cumulative_cost.rs 96.33% 4 Missing ⚠️
src/models/misc/sequencing_within_intervals.rs 96.00% 2 Missing ⚠️
...t_tests/models/misc/sequencing_within_intervals.rs 94.44% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #674      +/-   ##
==========================================
- Coverage   97.04%   97.04%   -0.01%     
==========================================
  Files         284      286       +2     
  Lines       38037    38289     +252     
==========================================
+ Hits        36914    37158     +244     
- Misses       1123     1131       +8     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@GiggleLiu
Copy link
Contributor Author

Implementation Summary

Changes

  • Added src/models/misc/sequencing_to_minimize_maximum_cumulative_cost.rs with Lehmer-code permutation encoding, precedence feasibility checks, cumulative-prefix bound evaluation, metadata, and an example instance.
  • Registered the new model across src/models/misc/mod.rs, src/models/mod.rs, src/lib.rs, src/unit_tests/trait_consistency.rs, src/example_db/fixtures/examples.json, and the generated reduction export JSON.
  • Extended CLI support in problemreductions-cli/src/cli.rs and problemreductions-cli/src/commands/create.rs, including shared precedence parsing and validation for sequencing commands.
  • Added coverage in src/unit_tests/models/misc/sequencing_to_minimize_maximum_cumulative_cost.rs and problemreductions-cli/tests/cli_tests.rs, and documented the model in docs/paper/reductions.typ with new bibliography entries.

Deviations from Plan

  • During review follow-up, I factored precedence parsing and range validation into shared CLI helpers so the new command and MinimumTardinessSequencing return consistent, flag-specific errors.
  • I expanded the test scope beyond the original plan to cover precedence serialization, invalid precedence parsing, negative costs/bounds, and constructor panic behavior for out-of-range precedence endpoints.

Open Questions

  • None.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds the SequencingToMinimizeMaximumCumulativeCost model (G&J SS7) to the core library, including schema/variant registration, example-db fixture, CLI pred create wiring, unit + CLI tests, and documentation/paper updates.

Changes:

  • Implement the new satisfaction model using Lehmer-code configurations and precedence/prefix-sum validation.
  • Wire the model into the library exports, example DB fixtures, and CLI creation (including shared precedence-pair parsing/validation).
  • Regenerate/update docs JSON and extend the paper with the new model description + references.

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/models/misc/sequencing_to_minimize_maximum_cumulative_cost.rs New model implementation + schema registration + variants + example-db hook
src/models/misc/mod.rs Registers the new misc model module and example-db specs
src/models/mod.rs Re-exports the new model from models
src/lib.rs Re-exports the new model from the public prelude
src/unit_tests/models/misc/sequencing_to_minimize_maximum_cumulative_cost.rs New unit tests covering construction, evaluation, brute-force, serialization, edge cases
src/unit_tests/trait_consistency.rs Adds trait-consistency coverage for the new model
src/example_db/fixtures/examples.json Adds canonical example fixture + satisfying configs
problemreductions-cli/src/cli.rs Adds --costs flag and help-line for the new problem type
problemreductions-cli/src/commands/create.rs Adds creation path for the new model and shared --precedence-pairs parsing/validation helpers
problemreductions-cli/tests/cli_tests.rs Adds CLI tests for pred create SequencingToMinimizeMaximumCumulativeCost (success + error cases)
docs/src/reductions/problem_schemas.json Adds generated schema entry for the new model
docs/src/reductions/reduction_graph.json Adds generated node entry for the new model (index shifts reflected in edges)
docs/paper/references.bib Adds references for series-parallel precedence results
docs/paper/reductions.typ Adds paper definition/description/example/figure section for the new model

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

…00-sequencing-to-minimize-maximum-cumulative-cost

# Conflicts:
#	docs/paper/reductions.typ
#	docs/src/reductions/problem_schemas.json
#	docs/src/reductions/reduction_graph.json
#	problemreductions-cli/src/commands/create.rs
#	src/example_db/fixtures/examples.json
#	src/lib.rs
#	src/models/misc/mod.rs
#	src/models/mod.rs
#	src/unit_tests/trait_consistency.rs
@GiggleLiu
Copy link
Contributor Author

Agentic Review Report

Structural Check

# Check Status
1 Model file exists (src/models/misc/sequencing_to_minimize_maximum_cumulative_cost.rs) PASS
2 inventory::submit! present PASS
3 #[derive(...Serialize, Deserialize)] on struct PASS (custom Deserialize impl with validation)
4 Problem trait impl PASS
5 SatisfactionProblem impl PASS
6 #[cfg(test)] + #[path = "..."] test link PASS
7 Test file exists PASS
8 Test file has >= 3 test functions PASS (12 test functions)
9 Registered in misc/mod.rs PASS
10 Re-exported in models/mod.rs PASS
11 declare_variants! entry exists PASS (default sat => "factorial(num_tasks)")
12 CLI resolve_alias entry PASS (canonical name auto-resolved via registry)
13 CLI create support PASS (handler at create.rs:1280)
14 Canonical model example registered PASS
15 Paper display-name entry PASS
16 Paper problem-def block PASS

Build Status: make test PASS, make clippy PASS, make fmt-check PASS

Semantic Review:

  • evaluate() correctness: OK — Lehmer code decoding, precedence checking, and cumulative cost bound checking are all correct. Manually verified with the 6-task example.
  • dims() correctness: OK — [n, n-1, ..., 1] is the correct Lehmer code dimension space for n! permutations.
  • num_tasks() and num_precedences() getters: OK.
  • Custom Deserialize with validation: OK — follows the unchecked struct pattern, rejects invalid precedence endpoints.
  • Cyclic precedences handled correctly (unsatisfiable, not invalid).
  • Complexity "factorial(num_tasks)": acceptable for brute-force.

Issue Compliance:

# Check Status
1 Problem name matches OK
2 Mathematical definition matches OK (Garey & Johnson SS7)
3 Problem type (sat) matches OK
4 Type parameters OK (none)
5 Configuration space OK (Lehmer code — justified improvement over issue's position-index suggestion)
6 Feasibility check OK
7 Complexity OK
8 Schema DEVIATION — issue proposed predecessors: Vec<Vec<usize>> (adjacency list), implementation uses precedences: Vec<(usize, usize)> (edge list). Edge list is consistent with MinimumTardinessSequencing. Justified improvement.
9 Example instance OK

Additional changes: SequencingWithinIntervals gained custom Deserialize validation (beneficial improvement). examples.json fixture changes are benign solver enumeration order non-determinism.

Result: 16/16 structural, 9/9 issue compliance — all passed.


Quality Check

Design Principles:

  • DRY (Minor): Lehmer-code decode logic is triplicated across sequencing_to_minimize_maximum_cumulative_cost.rs:92-107, minimum_tardiness_sequencing.rs:145-154, flow_shop_scheduling.rs:180-189. Pre-existing pattern this PR follows, not introduced here.
  • DRY (Minor): Precedence validation duplicated between new model (sequencing_to_minimize_maximum_cumulative_cost.rs:130-152) and minimum_tardiness_sequencing.rs:84-97. New model uses a better extract-and-reuse pattern.
  • KISS: OK — straightforward implementation, Lehmer code is well-chosen.
  • HC/LC: OK — single-responsibility functions, self-contained model file.

HCI (CLI):

  • Error messages are actionable with usage examples.
  • --costs flag uses allow_hyphen_values = true for negative costs.
  • Precedence pair parsing reuses existing parse_precedence_pairs helper.
  • no-flags-shows-help test verifies discoverability.

Test Quality:

  • 12 unit tests covering: creation/accessors, satisfying evaluation, tight bound rejection, precedence violation, invalid configs, brute-force solver, unsatisfiable cycle, paper example (counts 5 solutions), empty instance, invalid precedence panic, serialization roundtrip, deserialize rejection.
  • Tests are substantive with concrete value checks and adversarial cases.
  • 6-task canonical instance provides non-trivial coverage (720 permutations).

Issues found: 0 critical, 0 important, 3 minor (all DRY/pre-existing patterns).


Agentic Feature Tests

Test Status
CLI Build PASSED
pred list — catalog presence PASSED (appears among 49 problems)
pred show SequencingToMinimizeMaximumCumulativeCost PASSED (fields, complexity, description all correct)
pred create --example SequencingToMinimizeMaximumCumulativeCost PASSED (6 tasks, 6 precedences, bound=4)
pred solve (default ILP) EXPECTED FAILURE (no reductions — correct error message suggests --solver brute-force)
pred solve --solver brute-force PASSED (solution [0,0,0,0,0,0] evaluates to true)
Case-insensitive lookup PASSED
Full test suite (cargo test) PASSED (2144 unit + 62 integration + 57 doc tests)
cargo clippy PASSED
cargo fmt --check PASSED

Solution verification: Lehmer code [0,0,0,0,0,0] decodes to identity schedule [0,1,2,3,4,5] with cumulative sums [2,1,4,2,3,0], max=4 ≤ K=4. Confirmed correct.

Issues found: 0 confirmed bugs. The only observation is that default ILP solving is unavailable (no reductions registered), which is expected for a new standalone model.


Generated by review-pipeline

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Model] SequencingToMinimizeMaximumCumulativeCost

2 participants